package com.ajview.core.config.model;

import com.ajview.common.core.constant.Constants;
import com.ajview.common.core.factory.YamlPropertySourceFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * @author ZhangJunJie
 * @Date 2022-10-07
 * <p>
 * 概要：核心配置文件AjView节点模型
 */
@PropertySource(value = "classpath:config/ajview-core-config.yml", factory = YamlPropertySourceFactory.class, encoding = "UTF-8")
@ConfigurationProperties(prefix = "ajview")
@Component
public class AjViewConfigModel {

    /**
     * 系统验证码模式
     * 可选值为：com.ajview.common.core.constant.Constants#CAPTCHA_PRODUCER_MATH
     * 和 com.ajview.common.core.constant.Constants#CAPTCHA_PRODUCER_CHAR
     * math 和 char
     * 不设置默认为：char
     */
    private static String captchaType;
    /**
     * 验证码开关
     */
    private static String captchaOnOff;
    /**
     * 系统名称
     */
    private String name;
    /**
     * 系统版本
     */
    private String version;

    public static String getCaptchaType() {
        switch (captchaType) {
            case Constants.CAPTCHA_PRODUCER_MATH:
            case Constants.CAPTCHA_PRODUCER_CHAR: {
                return captchaType;
            }
            default: {
                return Constants.CAPTCHA_PRODUCER_CHAR;
            }
        }
    }

    public void setCaptchaType(String captchaType) {
        AjViewConfigModel.captchaType = captchaType;
    }

    public static String getCaptchaOnOff() {
        return captchaOnOff;
    }

    public static void setCaptchaOnOff(String captchaOnOff) {
        AjViewConfigModel.captchaOnOff = captchaOnOff;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }
}
